def is_prime(n):
    if n < 2:
        return False
    for i in range(2, int(n ** 0.5) + 1):
        if n % i == 0:
            return False
    return True
a=list(input().split())
b=['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine']
s=0
for i in a:
    if i in b and len(a)==3:
        s = s * 10 + b.index(i)
    else:
        print("Wrong input")
        break
#print(s)
l_prime = s
r_prime = s
while True:
    if is_prime(l_prime):
        break
    l_prime -= 1
while True:
    if is_prime(r_prime):
        break
    r_prime += 1
closest_prime = min(s - l_prime, r_prime - s, key=abs)
if closest_prime == s - l_prime:
    print(l_prime)
else:
    print(r_prime)
